Repository navigation
fix(github-ci): validate the Turso pipeline response envelope (#6949) - #6950
Merged
Merged
Conversation
batch() decoded the /v2/pipeline body with a type assertion and read .results unguarded: a null 200 body escaped as a raw TypeError, a results-less 200 ({} or a scalar) resolved execute() as undefined and was read by callers as a successful ci_events/sink write, and a non-JSON body escaped as a bare SyntaxError. Validate the envelope in the client: non-JSON, non-object, and missing/non-array results all throw in the existing contract form (turso pipeline failed: malformed response), and execute() throws when the statement result is absent. Regression tests: test/turso.test.ts (7 cases) plus an end-to-end worker test that a results-less Turso 200 fails the delivery with 500 instead of answering ok. Suite 18/18 on the branch; the 6 new shape tests fail pre-fix.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6949.
What
pkgs/github-ci/worker/src/turso.tsdecoded the Turso/v2/pipelinebody with a type assertion and read.resultsunguarded, so a wrong-shape 200 was mishandled three ways (all reproduced pre-fix in probe~/git/fleet/probe-turso-shapewith the real module verbatim):null→ rawTypeError: null is not an object (evaluating 'out.results')escapes the client;{}/"ok"(noresults) →batch()returns[],execute()resolvesundefined, and callers that ignore the return (theworkflow_runci_events insert, the sink writes) read it as a successful write — the worker answers GitHub{ok: true}and the delivery is never retried;{}viaqueryText()→ downstreamTypeErroronundefined.response; non-JSON body → bareSyntaxErrorwith no Turso context.Change
batch(): a non-JSON body, a non-object body, or a missing/non-arrayresultsthrows in the client's existing contract form —turso pipeline failed: malformed response (not JSON | missing results). Per-statementtype:"error"results and HTTP non-2xx keep their existing errors.execute(): a missing/non-object statement result throwsturso pipeline failed: malformed response (missing statement result)instead of resolvingundefined.Tests
test/turso.test.ts(7 cases): well-formed envelope, per-statement error contract, null body, results-less object body, scalar body + queryText, non-JSON body, empty/null statement results.test/worker.test.ts: a results-less Turso 200 for the ci_events insert now fails the delivery with 500 naming the malformed response (pre-fix: 200 ok).tsc --noEmitclean; with the fix stashed, the 6 new shape tests fail and the controls pass. Post-fix probe: every wrong-shape case throws the contract error, controls unchanged.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.